home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Files / XTND 1.3.6 / Application Examples / PascalSource / XTEStyleSample.r < prev    next >
Encoding:
Text File  |  1992-01-17  |  11.2 KB  |  534 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware TextEdit Sample Application
  6. #
  7. #    TEStyleSample
  8. #
  9. #    TEStyleSample.r    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                        10/89
  15. #                2.0                        3/91
  16. #
  17. #    Components:    XTEStyleSample.p            March 29, 1991
  18. #                XTEStyleSampleGlue.a        March 29, 1991
  19. #                XTEStyleSample.r            March 29, 1991
  20. #                XTEStyleSample.h            March 29, 1991
  21. #                XTEStyleSample.make            March 29, 1991
  22. #
  23. #    TEStyleSample is an example application that demonstrates how 
  24. #    to initialize the commonly used toolbox managers, operate 
  25. #    successfully under MultiFinder, handle desk accessories and 
  26. #    create, grow, and zoom windows. Both styled and fundamental TextEdit 
  27. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  28. #    also shows how to create and maintain scrollbar controls as well
  29. #    as implementing a basic printing loop.
  30. #
  31. #    It does not by any means demonstrate all the techniques you 
  32. #    need for a large application. In particular, TEStyleSample does not 
  33. #    cover exception handling, multiple windows/documents, 
  34. #    sophisticated memory management, or undo. All of 
  35. #    these are vital parts of a normal full-sized application.
  36. #
  37. #    This application is an example of the form of a Macintosh 
  38. #    application; it is NOT a template. It is NOT intended to be 
  39. #    used as a foundation for the next world-class, best-selling, 
  40. #    600K application. A stick figure drawing of the human body may 
  41. #    be a good example of the form for a painting, but that does not 
  42. #    mean it should be used as the basis for the next Mona Lisa.
  43. #
  44. #    We recommend that you review this program, TESample or Sample before 
  45. #    beginning a new application. TESample is a simpler version of TEStyleSample
  46. #    without styles and Sample is a simple app. which doesn’t 
  47. #    use TextEdit or the Control Manager.
  48. #
  49. ------------------------------------------------------------------------------*/
  50.  
  51. #include "SysTypes.r"
  52. #include "Types.r"
  53. #include "XTEStyleSample.h"
  54.  
  55. resource 'vers' (1) {
  56.     0x02, 0x00, release, 0x00, verUS,
  57.     "2.00",
  58.     "2.00, Copyright © 1989-1991 Apple Computer, Inc."
  59. };
  60.  
  61. /* we use an MBAR resource to conveniently load all the menus */
  62.  
  63. resource 'MBAR' (rMenuBar, preload) {
  64.     { mApple, mFile, mEdit, mFont, mFontSize, mStyle };        /* six menus */
  65. };
  66.  
  67.  
  68. resource 'MENU' (mApple, preload) {
  69.     mApple, textMenuProc,
  70.     AllItems & ~MenuItem2,    /* disable dashed line, enable About and DAs */
  71.     enabled, apple,
  72.     {
  73.         "About XTEStyleSample…",
  74.             noicon, nokey, nomark, plain;
  75.         "-",
  76.             noicon, nokey, nomark, plain
  77.     }
  78. };
  79.  
  80. resource 'MENU' (mFile, preload) {
  81.     mFile, textMenuProc,
  82.     MenuItem12,                /* enable Quit only, program enables others */
  83.     enabled, "File",
  84.     {
  85.         "New",
  86.             noicon, "N", nomark, plain;
  87.         "Open",
  88.             noicon, "O", nomark, plain;
  89.         "-",
  90.             noicon, nokey, nomark, plain;
  91.         "Close",
  92.             noicon, "W", nomark, plain;
  93.         "Save",
  94.             noicon, "S", nomark, plain;
  95.         "Save As…",
  96.             noicon, nokey, nomark, plain;
  97.         "Revert",
  98.             noicon, nokey, nomark, plain;
  99.         "-",
  100.             noicon, nokey, nomark, plain;
  101.         "Page Setup…",
  102.             noicon, nokey, nomark, plain;
  103.         "Print…",
  104.             noicon, nokey, nomark, plain;
  105.         "-",
  106.             noicon, nokey, nomark, plain;
  107.         "Quit",
  108.             noicon, "Q", nomark, plain
  109.     }
  110. };
  111.  
  112. resource 'MENU' (mEdit, preload) {
  113.     mEdit, textMenuProc,
  114.     NoItems,                /* disable everything, program does the enabling */
  115.     enabled, "Edit",
  116.      {
  117.         "Undo",
  118.             noicon, "Z", nomark, plain;
  119.         "-",
  120.             noicon, nokey, nomark, plain;
  121.         "Cut",
  122.             noicon, "X", nomark, plain;
  123.         "Copy",
  124.             noicon, "C", nomark, plain;
  125.         "Paste",
  126.             noicon, "V", nomark, plain;
  127.         "Clear",
  128.             noicon, nokey, nomark, plain;
  129.         "-",
  130.             noicon, nokey, nomark, plain;
  131.         "Select All",
  132.             noicon, "A", nomark, plain
  133.     }
  134. };
  135.  
  136. /* Added for TEStyleSample */
  137. /* Font Menu */
  138. resource 'MENU' (mFont, preload) {
  139.     mFont, textMenuProc,
  140.     AllItems,                /* enable everything since these are fonts     */
  141.     enabled, "Font",
  142.      {
  143.      }
  144. };
  145.  
  146. /* Added for TEStyleSample */
  147. /* Size Menu Items */
  148. resource 'MENU' (mFontSize, preload) {
  149.     mFontSize, textMenuProc,
  150.     AllItems,                /* enable everything, since these are font sizes */
  151.     enabled, "Font Size",
  152.      {
  153.          "9 Point", noIcon, noKey, noMark, plain,
  154.         "10 Point", noIcon, noKey, noMark, plain,
  155.         "12 Point", noIcon, noKey, noMark, plain,
  156.         "14 Point", noIcon, noKey, noMark, plain,
  157.         "18 Point", noIcon, noKey, noMark, plain,
  158.         "24 Point", noIcon, noKey, noMark, plain,
  159.         "Other…", noIcon, noKey, noMark, plain
  160.      }
  161. };
  162.  
  163. /* Added for TEStyleSample */
  164. /* Style Menu Items */
  165. resource 'MENU' (mStyle, preload) {
  166.     mStyle, textMenuProc,
  167.     AllItems & ~MenuItem2,    /* enable everything except dash */
  168.     enabled, "Style",
  169.      {
  170.         "Plain",
  171.             noicon, "P", nomark, plain;
  172.         "-",
  173.             noicon, nokey, nomark, plain;
  174.         "Bold",
  175.             noicon, "B", nomark, bold;
  176.         "Italic",
  177.             noicon, "I", nomark, italic;
  178.         "Underline",
  179.             noicon, "U", nomark, underline;
  180.         "Outline",
  181.             noicon, nokey, nomark, outline;
  182.         "Shadow",
  183.             noicon, nokey, nomark, shadow
  184.     }
  185. };
  186.  
  187.  
  188. /* this ALRT and DITL are used as an About screen */
  189.  
  190. resource 'ALRT' (rAboutAlert, purgeable) {
  191.     {40, 20, 198, 320}, rAboutAlert, {
  192.         OK, visible, silent;
  193.         OK, visible, silent;
  194.         OK, visible, silent;
  195.         OK, visible, silent
  196.     };
  197. };
  198.  
  199. resource 'DITL' (rAboutAlert, purgeable) {
  200.     { /* array DITLarray: 5 elements */
  201.         /* [1] */
  202.         {130, 109, 150, 189},
  203.         Button {
  204.             enabled,
  205.             "Thanks!"
  206.         },
  207.         /* [2] */
  208.         {8, 10, 25, 322},
  209.         StaticText {
  210.             disabled,
  211.             "XTND-Capable Styled TextEdit Application"
  212.         },
  213.         /* [3] */
  214.         {29, 10, 63, 311},
  215.         StaticText {
  216.             disabled,
  217.             "Copyright © 1989-1991 Apple Computer\n"
  218.             "& Claris Corporation"
  219.         },
  220.         /* [4] */
  221.         {70, 10, 86, 138},
  222.         StaticText {
  223.             disabled,
  224.             "Brought to you by:"
  225.         },
  226.         /* [5] */
  227.         {89, 10, 123, 281},
  228.         StaticText {
  229.             disabled,
  230.             "Macintosh Developer Technical Support\n"
  231.             "& Claris Corporation"
  232.         }
  233.     }
  234. };
  235.  
  236.  
  237. /* this ALRT and DITL are used as an error screen */
  238.  
  239. resource 'ALRT' (rUserAlert, purgeable) {
  240.     {40, 20, 150, 260},
  241.     rUserAlert,
  242.     { /* array: 4 elements */
  243.         /* [1] */
  244.         OK, visible, silent,
  245.         /* [2] */
  246.         OK, visible, silent,
  247.         /* [3] */
  248.         OK, visible, silent,
  249.         /* [4] */
  250.         OK, visible, silent
  251.     }
  252. };
  253.  
  254.  
  255. resource 'DITL' (rUserAlert, purgeable) {
  256.     {    /* array DITLarray: 3 elements */
  257.         /* [1] */
  258.         {85, 86, 105, 166},
  259.         Button {
  260.             enabled,
  261.             "Sorry"
  262.         },
  263.         /* [2] */
  264.         {10, 60, 75, 228},
  265.         StaticText {
  266.             disabled,
  267.             "Error. ^0.\n^1"
  268.         },
  269.         /* [3] */
  270.         {8, 8, 40, 40},
  271.         Icon {
  272.             disabled,
  273.             2
  274.         }
  275.     }
  276. };
  277.  
  278.  
  279. /* this DLOG and DITL are used as a Font Size selector */
  280.  
  281. resource 'DLOG' (rFontSelect) {
  282.     {40, 40, 150, 256},
  283.     dBoxProc,
  284.     invisible,
  285.     nogoAway,
  286.     0x0,
  287.     rFontSelect,
  288.     ""
  289. };
  290.  
  291. resource 'DITL' (rFontSelect, purgeable) {
  292.     {    /* array DITLarray: 4 elements */
  293.         /* [1] */
  294.         {73, 138, 93, 197},
  295.         Button {
  296.             enabled,
  297.             "OK"
  298.         },
  299.         /* [2] */
  300.         {73, 45, 93, 103},
  301.         Button {
  302.             enabled,
  303.             "Cancel"
  304.         },
  305.         /* [3] */
  306.         {10, 46, 29, 210},
  307.         StaticText {
  308.             disabled,
  309.             "Choose New Font Size"
  310.         },
  311.         /* [4] */
  312.         {37, 89, 55, 130},
  313.         EditText {
  314.             disabled,
  315.             "10"
  316.         }
  317.     }
  318. };
  319.  
  320. resource 'ALRT' (kFileMessageID) {
  321.     {60, 84, 206, 356},
  322.     131,
  323.     {    /* array: 4 elements */
  324.         /* [1] */
  325.         OK, visible, silent,
  326.         /* [2] */
  327.         OK, visible, silent,
  328.         /* [3] */
  329.         OK, visible, silent,
  330.         /* [4] */
  331.         OK, visible, silent
  332.     }
  333. };
  334.  
  335. resource 'DITL' (kFileMessageID) {
  336.     {    /* array DITLarray: 2 elements */
  337.         /* [1] */
  338.         {117, 20, 143, 89},
  339.         Button {
  340.             enabled,
  341.             "Next"
  342.         },
  343.         /* [2] */
  344.         {9, 5, 111, 255},
  345.         StaticText {
  346.             enabled,
  347.             "^0^1^2^3"
  348.         }
  349.     }
  350. };
  351.  
  352. resource 'ALRT' (kTextRunsDispID) {
  353.     {60, 84, 306, 556},
  354.     134,
  355.     {    /* array: 4 elements */
  356.         /* [1] */
  357.         OK, visible, silent,
  358.         /* [2] */
  359.         OK, visible, silent,
  360.         /* [3] */
  361.         OK, visible, silent,
  362.         /* [4] */
  363.         OK, visible, silent
  364.     }
  365. };
  366.  
  367. resource 'DITL' (kTextRunsDispID) {
  368.     {    /* array DITLarray: 4 elements */
  369.         /* [1] */
  370.         {211, 190, 237, 259},
  371.         Button {
  372.             enabled,
  373.             "Next"
  374.         },
  375.         /* [2] */
  376.         {54, 11, 193, 465},
  377.         StaticText {
  378.             enabled,
  379.             "(^0^1)"
  380.         },
  381.         /* [3] */
  382.         {15, 52, 36, 114},
  383.         StaticText {
  384.             enabled,
  385.             "Text Run"
  386.         },
  387.         /* [4] */
  388.         {14, 315, 35, 429},
  389.         StaticText {
  390.             enabled,
  391.             "Count = ^2"
  392.         }
  393.     }
  394. };
  395.  
  396. resource 'WIND' (rDocWindow, preload, purgeable) {
  397.     {64, 60, 314, 460},
  398.     zoomDocProc, invisible, goAway, 0x0, "untitled"
  399. };
  400.  
  401.  
  402. resource 'CNTL' (rVScroll, preload, purgeable) {
  403.     {-1, 385, 236, 401},
  404.     0, visible, 0, 0, scrollBarProc, 0, ""
  405. };
  406.  
  407.  
  408. resource 'CNTL' (rHScroll, preload, purgeable) {
  409.     {235, -1, 251, 386},
  410.     0, visible, 0, 0, scrollBarProc, 0, ""
  411. };
  412.  
  413. resource 'STR#' (kErrStrings, purgeable) {
  414.     {
  415.     "You must run on 512Ke or later";
  416.     "Application Memory Size is too small";
  417.     "Not enough memory to run TEStyleSample";
  418.     "Not enough memory to do Cut";
  419.     "Cannot do Cut";
  420.     "Cannot do Copy";
  421.     "Cannot exceed 32,000 characters with Paste";
  422.     "Not enough memory to do Paste";
  423.     "Cannot create window";
  424.     "Cannot exceed 32,000 characters";
  425.     "Cannot do Paste";
  426.     "Cannot do Import/Export";
  427.     "Error while trying to load translator resource";
  428.     "Error while opening import file resources";
  429.     "Error reading resources from document";
  430.     "Error opening document";
  431.     "Error initializing translator";
  432.     "Error deleting previous file";
  433.     "Could not create file";
  434.     "Error opening file"
  435.     }
  436. };
  437.  
  438. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  439.  
  440. resource 'SIZE' (-1) {
  441.     dontSaveScreen,
  442.     acceptSuspendResumeEvents,
  443.     enableOptionSwitch,
  444.     canBackground,                /* we can background; we don't currently, but our sleep value */
  445.                                 /* guarantees we don't hog the Mac while we are in the background */
  446.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  447.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  448.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  449.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  450.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  451.     reserved,
  452.     reserved,
  453.     reserved,
  454.     reserved,
  455.     reserved,
  456.     reserved,
  457.     reserved,
  458.     kPrefSize * 1024,
  459.     kMinSize * 1024
  460. };
  461.  
  462.  
  463. type 'XTND' as 'STR ';
  464.  
  465.  
  466. resource 'XTND' (0) {
  467.     "XTND-Capable Styled TextEdit Application"
  468. };
  469.  
  470.  
  471. resource 'BNDL' (128) {
  472.     'XTND',
  473.     0,
  474.     {
  475.         'ICN#',
  476.         {
  477.             0, 128
  478.         },
  479.         'FREF',
  480.         {
  481.             0, 128
  482.         }
  483.     }
  484. };
  485.  
  486.  
  487. resource 'FREF' (128) {
  488.     'APPL',
  489.     0,
  490.     ""
  491. };
  492.  
  493.  
  494. resource 'ICN#' (128) {
  495.     {    /* array: 2 elements */
  496.         /* [1] */
  497.         $"0430 4000 0A50 A000 0B91 1002 0822 0803"
  498.         $"1224 0405 2028 7FF9 4010 2011 8000 1011"
  499.         $"8802 2012 7405 4014 0208 8814 0410 4418"
  500.         $"0820 2214 1044 1052 1882 08B1 0D11 1112"
  501.         $"0A08 2204 0844 4408 0820 8810 0811 1020"
  502.         $"0802 A040 0804 4080 0808 0100 0804 0200"
  503.         $"0FFE 0400 0002 0800 0001 1000 0000 A000"
  504.         $"0000 40",
  505.         /* [2] */
  506.         $"0430 4000 0E70 E000 0FF1 F002 0FE3 F803"
  507.         $"1FE7 FC07 3FEF FFFF 7FFF FFFF FFFF FFFF"
  508.         $"FFFF FFFE 7FFF FFFC 01FF FFFC 03FF FFF8"
  509.         $"07FF FFFC 0FFF FFFE 1FFF FFFF 0FFF FFFE"
  510.         $"0FFF FFFC 0FFF FFF8 0FFF FFF0 0FFF FFE0"
  511.         $"0FFF FFC0 0FFF FF80 0FFF FF00 0FFF FE00"
  512.         $"0FFF FC00 0003 F800 0001 F000 0000 E000"
  513.         $"0000 40"
  514.     }
  515. };
  516.  
  517. /*    XTND STR# resources */
  518.  
  519. resource 'STR#' (25003, "Claris ƒ names", purgeable) {
  520.     {    /* array StringArray: 1 elements */
  521.         /* [1] */
  522.         "Claris"
  523.     }
  524. };
  525.  
  526. resource 'STR#' (25004, "Claris XTND names", purgeable) {
  527.     {    /* array StringArray: 2 elements */
  528.         /* [1] */
  529.         "Claris Translators",
  530.         /* [2] */
  531.         "Claris XTND System"
  532.     }
  533. };
  534.